package com.jxs.android.weixi.db;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.jxs.android.weixi.WeixiApplication;

public class CustomerParamHolder {

	static public interface Key {
		static final String IS_FIRST_RUN_OVERED = "is_first_run_overed";
		static final String CURRENT_USER_PWD = "current_user_pwd";

	}

	static public interface Value {
		static final String PARAM_YES = "1";
		static final String PARAM_NO = "0";
	}

	static public interface Prefix {
		public static final String SHARED_PREFERENCE_NAME_PREFIX = "prefix_";
	}

	public static boolean isFirstRunOvered() {
		return Value.PARAM_YES.equals(CustomerParamHolder.getParamValue(CustomerParamHolder.Key.IS_FIRST_RUN_OVERED, WeixiApplication.getUserInfo().getImsi()));
	}

	public static void saveOrUpdate(String key, String value, String phone) {
		SharedPreferences sharedPrefs = WeixiApplication.getApplication().getSharedPreferences(Prefix.SHARED_PREFERENCE_NAME_PREFIX + phone, Context.MODE_PRIVATE);
		Editor editor = sharedPrefs.edit();
		editor.putString(key, value);
		editor.commit();
	}

	public static String getParamValue(String key, String phone) {
		SharedPreferences sharedPrefs = WeixiApplication.getApplication().getSharedPreferences(Prefix.SHARED_PREFERENCE_NAME_PREFIX + phone, Context.MODE_PRIVATE);
		return sharedPrefs.getString(key, "0");
	}

}
